import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SaleReportVO, SaleReportForm, SaleReportQuery } from '@/api/crm/saleReport/types';

/**
 * 查询销售日报列表
 * @param query
 * @returns {*}
 */

export const listSaleReport = (query?: SaleReportQuery): AxiosPromise<SaleReportVO[]> => {
  return request({
    url: '/crm/saleReport/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询销售日报详细
 * @param id
 */
export const getSaleReport = (id: string | number): AxiosPromise<SaleReportVO> => {
  return request({
    url: '/crm/saleReport/' + id,
    method: 'get'
  });
};

/**
 * 新增销售日报
 * @param data
 */
export const addSaleReport = (data: SaleReportForm) => {
  return request({
    url: '/crm/saleReport',
    method: 'post',
    data: data
  });
};

/**
 * 修改销售日报
 * @param data
 */
export const updateSaleReport = (data: SaleReportForm) => {
  return request({
    url: '/crm/saleReport',
    method: 'put',
    data: data
  });
};

/**
 * 删除销售日报
 * @param id
 */
export const delSaleReport = (id: string | number | Array<string | number>) => {
  return request({
    url: '/crm/saleReport/' + id,
    method: 'delete'
  });
};
